<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tk="http://www.qdocuments.net" exclude-result-prefixes="tk">
  <xsl:import href="DetailTemplate_Trans.xslt"/>
  <xsl:import href="DetailFrame.xslt"/>
  <xsl:import href="DetailListFrame.xslt"/>
  <xsl:output method="html" indent="no"/>
  <xsl:variable name="tk:AllResolvers" select="$tk:XmlFile/Toolkit/tk:Module/tk:Resolvers"/>
  <xsl:variable name="tk:MainResolver">
    <xsl:choose>
      <xsl:when test="count($tk:AllResolvers/tk:Resolver) = 1">
        <xsl:value-of select="$tk:AllResolvers/tk:Resolver/tk:RegName"/>
      </xsl:when>
      <xsl:when test="count($tk:AllResolvers/tk:Resolver[@Main='true']) = 1">
        <xsl:value-of select="($tk:AllResolvers/tk:Resolver[@Main='true'])/tk:RegName"/>
      </xsl:when>
      <xsl:when test="count($tk:AllResolvers/tk:Resolver[@List='true' and @Type != 'View']) = 1">
        <xsl:value-of select="($tk:AllResolvers/tk:Resolver[@List='true' and @Type != 'View'])/tk:RegName"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$tk:AllResolvers/tk:Resolver[1]/tk:RegName"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="tk:Tables" select="$tk:AllXmlNodeSet[@RegName=$tk:MainResolver]"/>
  <xsl:template match="/">
    <input type="hidden" name="PageTitle" value="{$tk:PageTitle}"/>
    <table width="100%" border="0" cellspacing="0" cellpadding="6">
      <tr>
        <td class="title">
          <xsl:call-template name="tk:PageTitle"/>
          <hr class="hr2"/>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellpadding="3" cellspacing="0" class="tb-list">
            <xsl:call-template name="tk:Content">
              <xsl:with-param name="Method" select="'Detail'"/>
            </xsl:call-template>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0" cellpadding="2">
            <tr>
              <td height="30">
                <xsl:call-template name="tk:WhiteSpace"/>
              </td>
              <td align="right">
                <xsl:apply-templates select="$tk:XmlFile/Toolkit/tk:Module" mode="tk:Button"/>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
          <xsl:call-template name="tk:DetailList"/>
        </td>
      </tr>
    </table>
  </xsl:template>
  <xsl:template name="tk:DetailList">
    <xsl:variable name="DetailResolvers" select="$tk:XmlFile/Toolkit/tk:Module/tk:Resolvers/tk:Resolver[@DetailList and @DetailList = 'true']"/>
    <table cellpadding="2" cellspacing="0" border="0" width="100%">
      <tr>
        <xsl:for-each select="$DetailResolvers">
          <xsl:call-template name="tk:DetailTitlePage">
            <xsl:with-param name="Table" select="$tk:AllXmlNodeSet[@RegName=current()/tk:RegName]"/>
          </xsl:call-template>
        </xsl:for-each>
        <td width="99%">
          <input type="hidden" name="th" value="th{$tk:AllXmlNodeSet[@RegName=$DetailResolvers[1]/tk:RegName]/@TableName}"/>
          <input type="hidden" name="td" value="td{$tk:AllXmlNodeSet[@RegName=$DetailResolvers[1]/tk:RegName]/@TableName}"/>
        </td>
      </tr>
    </table>
    <table cellpadding="2" cellspacing="0" border="0" width="100%">
      <xsl:for-each select="$DetailResolvers">
        <xsl:call-template name="tk:SingleDetailListPage">
          <xsl:with-param name="Table" select="$tk:AllXmlNodeSet[@RegName=current()/tk:RegName]"/>
          <xsl:with-param name="Source" select="@Source"/>
          <xsl:with-param name="DListRefParams" select="tk:DListRefParams"/>
        </xsl:call-template>
      </xsl:for-each>
    </table>
  </xsl:template>
  <xsl:template match="tk:Module" mode="tk:Button">
    <xsl:call-template name="tk:Button">
      <xsl:with-param name="DListRefParams" select="tk:Resolvers/tk:Resolver[@List='true']/tk:DListRefParams"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="tk:Module[tk:DataSet='ListDetail' or tk:DataSet='ListDetailXml']" mode="tk:Button">
    <xsl:call-template name="tk:CancelButton"/>
  </xsl:template>
</xsl:stylesheet>
